<?php
include_once("dbconnect/db.php");
include_once("Common.php");
Class Result
{
	var $errorMessage;
	
	var $videoId;
	
	var $videoName;
	
	var $videoHtml = "";
	
	var $ref = "";
	
	var $top_link = "";
	
	// 毎Eージのレコード数
	var $RECORD_NUMBER_PER_PAGE = 5;
	
	function mytask()
	{
		// 初期化の場合
		if(isset($_POST["act"]) == false)
		{
			$this->videoId = $_GET["videoId"];
			if(isset($_SERVER['HTTP_REFERER']) )
			{ 
				$this->ref = $_SERVER['HTTP_REFERER'];
				if(isset($_GET["keyword"]))
				{
					if(strpos($this->ref,"?") === false)
					{
						$this->ref .= "?keyword=".urlencode($_GET["keyword"]);
					}
					else
					{
						$this->ref .= "&keyword=".urlencode($_GET["keyword"]);
					}
				}
			}
			if(strpos($this->ref,"top_page.php") === false)
			{
				$this->top_link = "<a href=".$this->ref.">検索結果</a>>";
			}
			else
			{
				$this->top_link = "";
			}
			$this->getVideoInfo();
		}
		else if($_POST["act"] == "submit")
		{
			
		}
	}
	
	function initForm()
	{

	}
	
	function getSelectSql()
	{
		$sql = "select `entrylist`.`title`,`videolist`.`cid`,`videolist`.`time` ";
		$sql = $sql."from `entrylist`,`videolist` ";
		$sql = $sql."where `videolist`.`video_id` =  ";
		$sql = $sql.$this->videoId." ";
		$sql = $sql."and `videolist`.`site_id` = 1 ";
		$sql = $sql."and `videolist`.`open_flag` = 1 ";
		$sql = $sql."and `entrylist`.`open_flag` = 1 ";
		$sql = $sql."and `videolist`.`cid` is not null ";
		$sql = $sql."and `entrylist`.`entry_id` = `videolist`.`entry_id` ";
		return $sql;
	}	
	
	function getVideoInfo()
	{
		$sql = $this->getSelectSql();
		
		$result = mysql_query($sql);
		$rows = mysql_num_rows($result);

		
		if($rows > 0)
		{		
			$data = mysql_fetch_array($result);
			$this->videoName = $data["title"];	
			$this->videoHtml = $this->videoHtml."<hr color=#3399FF>".$data["title"]."(".$data["time"]."秒)<br>";
			$this->videoHtml = $this->videoHtml."<img src=http://i1.ytimg.com/vi/".$data["cid"]."/default.jpg align=left><br><br><br><br><br>";
			$this->videoHtml = $this->videoHtml."<a href=format_start.php?UID=NULLGWDOCOMO&type=1&videoId=".$this->videoId.">動画を再生/保存する</a><br/>";
			$this->videoHtml = $this->videoHtml."<a href=format_start.php?UID=NULLGWDOCOMO&type=2&videoId=".$this->videoId.">ｻﾑﾈｲﾙ画像を作る</a><br/>";
			$this->videoHtml = $this->videoHtml."<a href=format_start.php?UID=NULLGWDOCOMO&type=4&videoId=".$this->videoId.">待ち受け画像を作る</a><br/>";
			$this->videoHtml = $this->videoHtml."<a href=format_start.php?UID=NULLGWDOCOMO&type=3&videoId=".$this->videoId.">ﾃﾞｺﾒ素材を作る</a><br/>";	
		}
		// データがない場合
		else
		{
			
		}
	}
}
?>